// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the Artifact Registry API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_artifactregistry_v1::client::ArtifactRegistry;
/// let client = ArtifactRegistry::builder().build().await?;
/// // use `client` to make requests to the Artifact Registry API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// The Artifact Registry API service.
///
/// Artifact Registry is an artifact management system for storing artifacts
/// from different package management systems.
///
/// The resources managed by this API are:
///
/// * Repositories, which group packages and their data.
/// * Packages, which group versions and their tags.
/// * Versions, which are specific forms of a package.
/// * Tags, which represent alternative names for versions.
/// * Files, which contain content and are optionally associated with a Package
///   or Version.
///
/// # Configuration
///
/// To configure `ArtifactRegistry` use the `with_*` methods in the type returned
/// by [builder()][ArtifactRegistry::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://artifactregistry.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::artifact_registry::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::artifact_registry::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `ArtifactRegistry` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `ArtifactRegistry` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct ArtifactRegistry {
    inner: std::sync::Arc<dyn super::stub::dynamic::ArtifactRegistry>,
}

impl ArtifactRegistry {
    /// Returns a builder for [ArtifactRegistry].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_artifactregistry_v1::client::ArtifactRegistry;
    /// let client = ArtifactRegistry::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::artifact_registry::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::artifact_registry::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::ArtifactRegistry + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ArtifactRegistry>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::ArtifactRegistry> {
        super::transport::ArtifactRegistry::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::ArtifactRegistry> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::ArtifactRegistry::new)
    }

    /// Lists docker images.
    pub fn list_docker_images(&self) -> super::builder::artifact_registry::ListDockerImages {
        super::builder::artifact_registry::ListDockerImages::new(self.inner.clone())
    }

    /// Gets a docker image.
    pub fn get_docker_image(&self) -> super::builder::artifact_registry::GetDockerImage {
        super::builder::artifact_registry::GetDockerImage::new(self.inner.clone())
    }

    /// Lists maven artifacts.
    pub fn list_maven_artifacts(&self) -> super::builder::artifact_registry::ListMavenArtifacts {
        super::builder::artifact_registry::ListMavenArtifacts::new(self.inner.clone())
    }

    /// Gets a maven artifact.
    pub fn get_maven_artifact(&self) -> super::builder::artifact_registry::GetMavenArtifact {
        super::builder::artifact_registry::GetMavenArtifact::new(self.inner.clone())
    }

    /// Lists npm packages.
    pub fn list_npm_packages(&self) -> super::builder::artifact_registry::ListNpmPackages {
        super::builder::artifact_registry::ListNpmPackages::new(self.inner.clone())
    }

    /// Gets a npm package.
    pub fn get_npm_package(&self) -> super::builder::artifact_registry::GetNpmPackage {
        super::builder::artifact_registry::GetNpmPackage::new(self.inner.clone())
    }

    /// Lists python packages.
    pub fn list_python_packages(&self) -> super::builder::artifact_registry::ListPythonPackages {
        super::builder::artifact_registry::ListPythonPackages::new(self.inner.clone())
    }

    /// Gets a python package.
    pub fn get_python_package(&self) -> super::builder::artifact_registry::GetPythonPackage {
        super::builder::artifact_registry::GetPythonPackage::new(self.inner.clone())
    }

    /// Imports Apt artifacts. The returned Operation will complete once the
    /// resources are imported. Package, Version, and File resources are created
    /// based on the imported artifacts. Imported artifacts that conflict with
    /// existing resources are ignored.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn import_apt_artifacts(&self) -> super::builder::artifact_registry::ImportAptArtifacts {
        super::builder::artifact_registry::ImportAptArtifacts::new(self.inner.clone())
    }

    /// Imports Yum (RPM) artifacts. The returned Operation will complete once the
    /// resources are imported. Package, Version, and File resources are created
    /// based on the imported artifacts. Imported artifacts that conflict with
    /// existing resources are ignored.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn import_yum_artifacts(&self) -> super::builder::artifact_registry::ImportYumArtifacts {
        super::builder::artifact_registry::ImportYumArtifacts::new(self.inner.clone())
    }

    /// Lists repositories.
    pub fn list_repositories(&self) -> super::builder::artifact_registry::ListRepositories {
        super::builder::artifact_registry::ListRepositories::new(self.inner.clone())
    }

    /// Gets a repository.
    pub fn get_repository(&self) -> super::builder::artifact_registry::GetRepository {
        super::builder::artifact_registry::GetRepository::new(self.inner.clone())
    }

    /// Creates a repository. The returned Operation will finish once the
    /// repository has been created. Its response will be the created Repository.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_repository(&self) -> super::builder::artifact_registry::CreateRepository {
        super::builder::artifact_registry::CreateRepository::new(self.inner.clone())
    }

    /// Updates a repository.
    pub fn update_repository(&self) -> super::builder::artifact_registry::UpdateRepository {
        super::builder::artifact_registry::UpdateRepository::new(self.inner.clone())
    }

    /// Deletes a repository and all of its contents. The returned Operation will
    /// finish once the repository has been deleted. It will not have any Operation
    /// metadata and will return a google.protobuf.Empty response.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_repository(&self) -> super::builder::artifact_registry::DeleteRepository {
        super::builder::artifact_registry::DeleteRepository::new(self.inner.clone())
    }

    /// Lists packages.
    pub fn list_packages(&self) -> super::builder::artifact_registry::ListPackages {
        super::builder::artifact_registry::ListPackages::new(self.inner.clone())
    }

    /// Gets a package.
    pub fn get_package(&self) -> super::builder::artifact_registry::GetPackage {
        super::builder::artifact_registry::GetPackage::new(self.inner.clone())
    }

    /// Deletes a package and all of its versions and tags. The returned operation
    /// will complete once the package has been deleted.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_package(&self) -> super::builder::artifact_registry::DeletePackage {
        super::builder::artifact_registry::DeletePackage::new(self.inner.clone())
    }

    /// Lists versions.
    pub fn list_versions(&self) -> super::builder::artifact_registry::ListVersions {
        super::builder::artifact_registry::ListVersions::new(self.inner.clone())
    }

    /// Gets a version
    pub fn get_version(&self) -> super::builder::artifact_registry::GetVersion {
        super::builder::artifact_registry::GetVersion::new(self.inner.clone())
    }

    /// Deletes a version and all of its content. The returned operation will
    /// complete once the version has been deleted.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_version(&self) -> super::builder::artifact_registry::DeleteVersion {
        super::builder::artifact_registry::DeleteVersion::new(self.inner.clone())
    }

    /// Deletes multiple versions across a repository. The returned operation will
    /// complete once the versions have been deleted.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn batch_delete_versions(&self) -> super::builder::artifact_registry::BatchDeleteVersions {
        super::builder::artifact_registry::BatchDeleteVersions::new(self.inner.clone())
    }

    /// Updates a version.
    pub fn update_version(&self) -> super::builder::artifact_registry::UpdateVersion {
        super::builder::artifact_registry::UpdateVersion::new(self.inner.clone())
    }

    /// Lists files.
    pub fn list_files(&self) -> super::builder::artifact_registry::ListFiles {
        super::builder::artifact_registry::ListFiles::new(self.inner.clone())
    }

    /// Gets a file.
    pub fn get_file(&self) -> super::builder::artifact_registry::GetFile {
        super::builder::artifact_registry::GetFile::new(self.inner.clone())
    }

    /// Deletes a file and all of its content. It is only allowed on generic
    /// repositories. The returned operation will complete once the file has been
    /// deleted.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_file(&self) -> super::builder::artifact_registry::DeleteFile {
        super::builder::artifact_registry::DeleteFile::new(self.inner.clone())
    }

    /// Updates a file.
    pub fn update_file(&self) -> super::builder::artifact_registry::UpdateFile {
        super::builder::artifact_registry::UpdateFile::new(self.inner.clone())
    }

    /// Lists tags.
    pub fn list_tags(&self) -> super::builder::artifact_registry::ListTags {
        super::builder::artifact_registry::ListTags::new(self.inner.clone())
    }

    /// Gets a tag.
    pub fn get_tag(&self) -> super::builder::artifact_registry::GetTag {
        super::builder::artifact_registry::GetTag::new(self.inner.clone())
    }

    /// Creates a tag.
    pub fn create_tag(&self) -> super::builder::artifact_registry::CreateTag {
        super::builder::artifact_registry::CreateTag::new(self.inner.clone())
    }

    /// Updates a tag.
    pub fn update_tag(&self) -> super::builder::artifact_registry::UpdateTag {
        super::builder::artifact_registry::UpdateTag::new(self.inner.clone())
    }

    /// Deletes a tag.
    pub fn delete_tag(&self) -> super::builder::artifact_registry::DeleteTag {
        super::builder::artifact_registry::DeleteTag::new(self.inner.clone())
    }

    /// Creates a rule.
    pub fn create_rule(&self) -> super::builder::artifact_registry::CreateRule {
        super::builder::artifact_registry::CreateRule::new(self.inner.clone())
    }

    /// Lists rules.
    pub fn list_rules(&self) -> super::builder::artifact_registry::ListRules {
        super::builder::artifact_registry::ListRules::new(self.inner.clone())
    }

    /// Gets a rule.
    pub fn get_rule(&self) -> super::builder::artifact_registry::GetRule {
        super::builder::artifact_registry::GetRule::new(self.inner.clone())
    }

    /// Updates a rule.
    pub fn update_rule(&self) -> super::builder::artifact_registry::UpdateRule {
        super::builder::artifact_registry::UpdateRule::new(self.inner.clone())
    }

    /// Deletes a rule.
    pub fn delete_rule(&self) -> super::builder::artifact_registry::DeleteRule {
        super::builder::artifact_registry::DeleteRule::new(self.inner.clone())
    }

    /// Updates the IAM policy for a given resource.
    pub fn set_iam_policy(&self) -> super::builder::artifact_registry::SetIamPolicy {
        super::builder::artifact_registry::SetIamPolicy::new(self.inner.clone())
    }

    /// Gets the IAM policy for a given resource.
    pub fn get_iam_policy(&self) -> super::builder::artifact_registry::GetIamPolicy {
        super::builder::artifact_registry::GetIamPolicy::new(self.inner.clone())
    }

    /// Tests if the caller has a list of permissions on a resource.
    pub fn test_iam_permissions(&self) -> super::builder::artifact_registry::TestIamPermissions {
        super::builder::artifact_registry::TestIamPermissions::new(self.inner.clone())
    }

    /// Retrieves the Settings for the Project.
    pub fn get_project_settings(&self) -> super::builder::artifact_registry::GetProjectSettings {
        super::builder::artifact_registry::GetProjectSettings::new(self.inner.clone())
    }

    /// Updates the Settings for the Project.
    pub fn update_project_settings(
        &self,
    ) -> super::builder::artifact_registry::UpdateProjectSettings {
        super::builder::artifact_registry::UpdateProjectSettings::new(self.inner.clone())
    }

    /// Retrieves the VPCSC Config for the Project.
    pub fn get_vpcsc_config(&self) -> super::builder::artifact_registry::GetVPCSCConfig {
        super::builder::artifact_registry::GetVPCSCConfig::new(self.inner.clone())
    }

    /// Updates the VPCSC Config for the Project.
    pub fn update_vpcsc_config(&self) -> super::builder::artifact_registry::UpdateVPCSCConfig {
        super::builder::artifact_registry::UpdateVPCSCConfig::new(self.inner.clone())
    }

    /// Updates a package.
    pub fn update_package(&self) -> super::builder::artifact_registry::UpdatePackage {
        super::builder::artifact_registry::UpdatePackage::new(self.inner.clone())
    }

    /// Lists attachments.
    pub fn list_attachments(&self) -> super::builder::artifact_registry::ListAttachments {
        super::builder::artifact_registry::ListAttachments::new(self.inner.clone())
    }

    /// Gets an attachment.
    pub fn get_attachment(&self) -> super::builder::artifact_registry::GetAttachment {
        super::builder::artifact_registry::GetAttachment::new(self.inner.clone())
    }

    /// Creates an attachment. The returned Operation will finish once the
    /// attachment has been created. Its response will be the created attachment.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_attachment(&self) -> super::builder::artifact_registry::CreateAttachment {
        super::builder::artifact_registry::CreateAttachment::new(self.inner.clone())
    }

    /// Deletes an attachment. The returned Operation will
    /// finish once the attachments has been deleted. It will not have any
    /// Operation metadata and will return a `google.protobuf.Empty` response.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_attachment(&self) -> super::builder::artifact_registry::DeleteAttachment {
        super::builder::artifact_registry::DeleteAttachment::new(self.inner.clone())
    }

    /// Exports an artifact.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn export_artifact(&self) -> super::builder::artifact_registry::ExportArtifact {
        super::builder::artifact_registry::ExportArtifact::new(self.inner.clone())
    }

    /// Lists information about the supported locations for this service.
    pub fn list_locations(&self) -> super::builder::artifact_registry::ListLocations {
        super::builder::artifact_registry::ListLocations::new(self.inner.clone())
    }

    /// Gets information about a location.
    pub fn get_location(&self) -> super::builder::artifact_registry::GetLocation {
        super::builder::artifact_registry::GetLocation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::artifact_registry::GetOperation {
        super::builder::artifact_registry::GetOperation::new(self.inner.clone())
    }
}
